
--[[
--------------------
--- ADMIN FLAGS ---
--------------------

+ - Has every admin flag/super admin.
c - Can create items
m - Message related admin (admin messages, events, etc..)
s - See all
t - Can bring/goto players
z - Can spawn common zombie
Z - Can remove common zombies

-------------------
-------------------
]]--


AdminConCommand( "rpa_createitem", "c", function( ply, cmd, arg )

	if( not arg[1] ) then
	
		ply:PrintMessage( 2, "List of items: " );
	
		for k, v in pairs( ItemsData ) do
		
		 	ply:PrintMessage( 2, k );
		
		end
		
		return;
	
	end
	
	local ent = CreateItemProp( arg[1] );
	
	if( ent ) then
	
		local trace = { }
		trace.start = ply:EyePos();
		trace.endpos = trace.start + ply:GetAimVector() * 120;
		trace.filter = ply;
		
		local tr = util.TraceLine( trace );
	
		ent:SetPos( tr.HitPos );
		ent:SetAngles( Angle( 0, 0, 0 ) );
		
		ent:Spawn();
	
	end

end );

AdminConCommand( "rpa_togglehorde", "z", function( ply, cmd, arg )

	HordePause = !HordePause;
	
	if( HordePause ) then
	
		ply:PrintMessage( 2, "Horde paused." );
	
	else
	
		ply:PrintMessage( 2, "Horde resumed." );
	
	end
	
end );

AdminConCommand( "rpa_createhorde", "z", function( ply, cmd, arg )

	local max = tonumber( arg[1] ) or 10;
	local delay = tonumber( arg[2] ) or .5;

	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 4096;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );

	CreateHordeSpot( tr.HitPos, max, delay );

end );

AdminConCommand( "rpa_clearhorde", "z", function( ply, cmd, arg )

	NPCHordes = { };

end );



AdminConCommand( "rpa_createcommon", "z", function( ply, cmd, arg )

	CreateCommonInfrontPlayer( ply );

end );

AdminConCommand( "rpa_clearcommon", "Z", function( ply, cmd, arg )

	ClearAllCommons();

end );


AdminConCommand( "rpa_bring", "t", function( ply, cmd, arg )

	local name = arg[1];
	local chat = false;
	
	if( arg[2] == "1" ) then
	
		chat = true;
	
	end
	
	local succ, ret = SearchPlayerName( name );
	
	if( succ ) then
			
		trace = { }
		trace.start = ply:EyePos();
		trace.endpos = trace.start + ply:GetAngles():Forward() * 50;
		trace.filter = ply;
		
		tr = util.TraceLine( trace );

	
		if( tr.Hit ) then

			trace = { }
			trace.start = ply:EyePos();
			trace.endpos = trace.start + ply:GetAngles():Forward() * -50;
			trace.filter = ply;
			
			tr = util.TraceLine( trace );
			
		end
		
		if( tr.Hit ) then
		
			trace = { }
			trace.start = ply:EyePos();
			trace.endpos = trace.start + ply:GetAngles():Right() * -50;
			trace.filter = ply;
			
			tr = util.TraceLine( trace );
			
		end
		
		if( tr.Hit ) then
		
			trace = { }
			trace.start = ply:EyePos();
			trace.endpos = trace.start + ply:GetAngles():Right() * 50;
			trace.filter = ply;
			
			tr = util.TraceLine( trace );
			
		end
		
		
		ret:SetPos( tr.HitPos - Vector( 0, 0, 64 ) );
	
	else
	
		if( chat ) then
			
			ply:PrintBlueMessage( ret );
	
		else
		
			ply:PrintMessage( 2, ret );
		
		end
	
	end

end );


AdminConCommand( "rpa_goto", "t", function( ply, cmd, arg )

	local name = arg[1];
	local chat = false;
	
	if( arg[2] == "1" ) then
	
		chat = true;
	
	end
		
	local succ, ret = SearchPlayerName( name );
	
	if( succ ) then
			
		local trace = { }
		trace.start = ret:EyePos();
		trace.endpos = trace.start + ret:GetAngles():Up() * 90;
		trace.filter = ret;
		
		local tr = util.TraceLine( trace );
	
		if( tr.Hit ) then

			trace = { }
			trace.start = ret:EyePos();
			trace.endpos = trace.start + ret:GetAngles():Forward() * 50;
			trace.filter = ret;
			
			tr = util.TraceLine( trace );
			
		end
		
		if( tr.Hit ) then

			trace = { }
			trace.start = ret:EyePos();
			trace.endpos = trace.start + ret:GetAngles():Forward() * -50;
			trace.filter = ret;
			
			tr = util.TraceLine( trace );
			
		end
		
		if( tr.Hit ) then
		
			trace = { }
			trace.start = ret:EyePos();
			trace.endpos = trace.start + ret:GetAngles():Right() * -50;
			trace.filter = ret;
			
			tr = util.TraceLine( trace );
			
		end
		
		if( tr.Hit ) then
		
			trace = { }
			trace.start = ret:EyePos();
			trace.endpos = trace.start + ret:GetAngles():Right() * 50;
			trace.filter = ret;
			
			tr = util.TraceLine( trace );
			
		end
		
		
		ply:SetPos( tr.HitPos - Vector( 0, 0, 64 ) );
	
	else
	
		if( chat ) then
			
			ply:PrintBlueMessage( ret );
	
		else
		
			ply:PrintMessage( 2, ret );
		
		end
	
	
	end

end );

AdminConCommand( "rpa_seeall", "s", function( ply, cmd, arg )

	ply:CallEvent( "TSA" );

end );

AdminConCommand( "rpa_adminyell", "m", function( ply, cmd, arg )

	local msg = "";
	
	for k, v in pairs( arg ) do
	
		msg = msg .. " " .. v;
	
	end

	umsg.Start( "Ayell" );
	
		umsg.String( ply:RPNick() );
		umsg.String( msg );
	
	umsg.End();

end );

AdminConCommand( "rpa_givetempadmin", "+", function( ply, cmd, arg )

	if( ply:GetTable().TempAdmin ) then return; end

	local name = arg[1];
	local flags = arg[2] or "+";

	local succ, ret = SearchPlayerName( name );
	
	if( succ ) then
	
		ret:GetTable().TempAdmin = true;
		ret:GetTable().AdminFlags = flags;
		
		ply:PrintMessage( 2, "Gave temp admin to " .. ret:RPNick() .. " with flags: " .. flags );
		ret:PrintBlueMessage( "Received temporary admin from " .. ply:RPNick() );
	
	else
	
		ply:PrintMessage( 2, ret );
	
	end

end );

